<template>
  <el-calendar v-model="currentDate">

    <template #dateCell="{date,data}">
      <div class="date-content">
        <span class="text">{{ dayFn(data.day) }}</span>
        <span v-if="restFn(date)" class="rest">休</span>
      </div>
    </template>

  </el-calendar>
</template>

<script>
export default {
  data() {
    return {
      currentDate: new Date()
    }
  },
  methods: {
    // 拿到每个隔的日期并分割出日
    dayFn(day) {
      return day.split('-')[2]
    },
    restFn(data) {
      return data.getDay() === 0 || data.getDay() === 6
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep .el-calendar-day {
  height: 50px;
}
.date-content {
  height: 40px;
  text-align: center;
  line-height: 40px;
  font-size: 14px;
}
// 休息时间
.date-content .rest {
  color: #fff;
  border-radius: 50%;
  background: rgb(250, 124, 77);
  width: 20px;
  height: 20px;
  line-height: 20px;
  display: inline-block;
  font-size: 12px;
  margin-left: 10px;
}
.date-content .text {
  width: 20px;
  height: 20px;
  line-height: 20px;
  display: inline-block;
}
// 当前日期
::v-deep .el-calendar-table td.is-selected .text {
  background: #409eff;
  color: #fff;
  border-radius: 50%;
}
</style>
